package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.utils.Key;
	import net.flashpunk.utils.Input;
    import net.flashpunk.Sfx;
	import net.flashpunk.graphics.Spritemap;
	/**
	 * ...
	 * @author OSEA
	 */
	public class MyEntity extends Entity
	{
		[Embed(source = 'resource/avril.mp3')]
        private const SHOOT:Class;
		[Embed(source = 'resource/player.png')]
        private const PLAYER:Class;
		 [Embed(source = 'resource/swordguy.png')]
        private const SWORDGUY:Class;
		public var shoot:Sfx = new Sfx(SHOOT);
		public var sprSwordguy:Spritemap = new Spritemap(SWORDGUY, 48, 32);
		
		public function MyEntity() 
		{
			graphic = new Image(PLAYER);
			setHitbox(50, 50);
			type = "myentity";
			Input.define("run", Key.UP, Key.DOWN, Key.RIGHT, Key.LEFT);
			sprSwordguy.add("stand", [0, 1, 2, 3, 4, 5], 10, true);
            sprSwordguy.add("run", [6, 7, 8, 9, 10, 11], 10, true);
			graphic = sprSwordguy;
		}
		
		override public function update():void
		{			
			if (Input.pressed("run")) 
			{
				sprSwordguy.play("run");
			}
			if (Input.released("run"))
			{
				sprSwordguy.play("stand");
			}
			if (Input.check(Key.LEFT))
			{
				x -= 5;
			}
 
			if (Input.check(Key.RIGHT))
			{
				x += 5;
			}
 
			if (Input.check(Key.UP))
			{
				y -= 5;
			}
 
			if (Input.check(Key.DOWN))
			{
				y += 5;
			}
			
			//trace("MyEntity updates");
			if (collide("monster", x, y))
			{
				trace("oh");
				shoot.play();
			}
		}
	}

}